﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using LynxBlogAPI.Models;

namespace LynxBlogAPI.Controllers
{
    public class BlogQueryController : ApiController
    {
        public List<BlogData> GetBlogEntryContains(string qryParam)
        {
            LynxWebLog_Context db = new LynxWebLog_Context();
            List<BlogData> pages = new List<BlogData>();
            try {
                string sqlQry = @"Select PageId, BlogId, Title, null as Description, WP-Page_Parent_Id, WP_Page_Order, 
                        IsPublished, DateCreated from tblPageData where contains (Description, @pqryParam)";
                pages = db.BlogDatas.SqlQuery(sqlQry, new SqlParameter("pqryParam", qryParam)).ToList();

                return pages;
            }
            catch (Exception ex) {
                Debug.Print(ex.Message);
            }
            return pages;
        }
    }
}
